﻿using System;
using System.ComponentModel;
using System.Reflection;

namespace StockholmsStad.Utilities
{
    public class EnumUtility
    {
        public static string GetEnumDescription(Enum enumValue)
        {
            FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString());

            var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);

            if (attributes != null && attributes.Length > 0)
                return attributes[0].Description;

            return string.Empty;
        }
    }
}
